// 资产 - 资金日志页
// import { isEmpty } from 'lodash'
import * as types from '@/store/mutation-types'
import api from '@/tools/api.js'
import promise from '@/tools/promise'
// import { SUCCESS_STATUS } from '@/config/status'
const state = {
  list: [],
  pageData: {
    total: 1,
    per_page: 15,
    current_page: 1,
    last_page: 1
  }
}

// mutations
const mutations = {
  [types.WITHDRAW_CASH_LIST] (state, payload) {
    state.list = payload.data
    state.pageData.total = Number(payload.total)
    state.pageData.per_page = Number(payload.per_page)
    state.pageData.current_page = Number(payload.current_page)
    state.pageData.last_page = Number(payload.last_page)
  }
}

// actions
const actions = {
  // 获取提现分页列表
  async getList ({ commit }, payload) {
    let config = {loading: true, loadingText: '正在获取提现分页列表'}
    let getRes = await api('serverfund/withdraw/Withdraw/adminWithdrawList', payload, config)
    commit(types.WITHDRAW_CASH_LIST, getRes.res)
  },
  // 审核提现
  async auditWithdraw ({ commit }, payload) {
    let config = {loading: true, loadingText: '正在审核提现'}
    let getRes = await api('serverfund/withdraw/Withdraw/auditWithdraw', payload, config)
    return promise(getRes)
  },
  // 审核转账
  async auditTransfer ({ commit }, payload) {
    let config = {loading: true, loadingText: '正在审核转账'}
    let getRes = await api('serverfund/withdraw/Withdraw/auditTransfer', payload, config)
    return promise(getRes)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}
